<%--
  Created by IntelliJ IDEA.
  User: WCX
  Date: 2024/12/9
  Time: 19:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.example.chapter9.ShanghusDao"%>
<%@ page import="com.example.chapter9.Shanghus"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>更新商户信息</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    String id = request.getParameter("id");
    String xm = request.getParameter("xm");
    String qy = request.getParameter("qy");
    String lxr = request.getParameter("lxr");
    String dh = request.getParameter("dh");

    if (xm != null && qy != null && lxr != null && dh != null) {
        Shanghus m = new Shanghus();
        m.setSh_name(xm);
        m.setSh_quyu(qy);
        m.setSh_lianxiren(lxr);
        m.setSh_dianhua(dh);
        m.setId(Integer.parseInt(id));
        ShanghusDao dao = new ShanghusDao();
        int row = dao.update(m);
        if (row > 0) {
            response.sendRedirect("index.jsp");
        } else {
           // out.println("更新失败！");
        }
    } else {
        ShanghusDao dao = new ShanghusDao();
        Shanghus shanghu = dao.findShById(Integer.parseInt(id));
        if (shanghu != null) {
%>
<form action="updateShanghu.jsp" method="post">
    <input type="hidden" name="id" value="<%=shanghu.getId()%>">
    <table width="90%" border="0">
        <tr>
            <td align="center">更新商户信息</td>
        </tr>
        <tr>
            <td align="center">
                <table width="90%" border="0">
                    <tr>
                        <td width="28%" align="right">商户名称</td>
                        <td width="72%" align="left"><input type="text" name="xm" value="<%=shanghu.getSh_name()%>"></td>
                    </tr>
                    <tr>
                        <td align="right">区域</td>
                        <td align="left"><input type="text" name="qy" value="<%=shanghu.getSh_quyu()%>"></td>
                    </tr>
                    <tr>
                        <td align="right">联系人</td>
                        <td align="left"><input type="text" name="lxr" value="<%=shanghu.getSh_lianxiren()%>"></td>
                    </tr>
                    <tr>
                        <td align="right">电话</td>
                        <td align="left"><input type="text" name="dh" value="<%=shanghu.getSh_dianhua()%>"></td>
                    </tr>
                </table>
                <p>
                    <input type="submit" name="Submit" value="更新商户信息">
                </p>
            </td>
        </tr>
    </table>
</form>
<%
        }
    }
%>
</body>
</html>